#include <bits/stdc++.h>
#define ll long long
#define i128 __int128
using namespace std;
ll T,n,m,L,V,p[100005],d[100005],v[100005],a[100005];
struct node{
	ll l,r;
}t[100005];
ll pos;
bool cmp(node A,node B)
{
	return A.r < B.r;
}
void solve()
{
	scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
	for(ll i = 1;i <= n;i++)
		scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
	for(ll i = 1;i <= m;i++)
		scanf("%lld",&p[i]);
	pos = 0;
	for(ll i = 1;i <= n;i++)
	{
		if(d[i] > p[m])
			continue;
		ll l = 1,r = m;
		while(l <= r)
		{
			ll mid = l + r >> 1;
			if(p[mid] < d[i])
				l = mid + 1;
			else
				r = mid - 1;
		}
		if(a[i] == 0)
		{
			if(v[i] > V)
				t[++pos] = {l,m};
			continue;
		}
		else if(a[i] > 0)
		{
			r = m;
			while(l <= r)
			{
				ll mid = l + r >> 1;
				if(v[i] * v[i] + 2 * a[i] * (p[mid] - d[i]) > V * V)
					r = mid - 1;
				else
					l = mid + 1;
			}
			if(l <= m)
				t[++pos] = {l,m};
			continue;
		}
		else
		{
			ll lp = l;
			r = m;
			while(l <= r)
			{
				ll mid = l + r >> 1;
				if(v[i] * v[i] + 2 * a[i] * (p[mid] - d[i]) > V * V)
					l = mid + 1;
				else
					r = mid - 1;
			}
			if(lp <= r)
				t[++pos] = {lp,r};
		}
	}
	sort(t + 1,t + 1 + pos,cmp);
	ll lst = -1,ans = 0;
	for(ll i = 1;i <= pos;i++)
		if(t[i].l > lst)
			lst = t[i].r,ans++;
	printf("%lld %lld\n",pos,m - ans);
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%lld",&T);
	while(T--)
		solve();
	return 0;
}